package com.wpzf.zxhc.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.wpzf.common.core.utils.ServletUtils;
import com.wpzf.common.core.web.domain.AjaxResult;
import com.wpzf.common.log.annotation.Log;
import com.wpzf.common.log.enums.BusinessType;
import com.wpzf.common.security.service.TokenService;
import com.wpzf.common.security.utils.SecurityUtils;
import com.wpzf.system.api.model.LoginUser;
import com.wpzf.zxhc.domain.*;
import com.wpzf.zxhc.mapper.DataUploadMapper;
import com.wpzf.zxhc.mapper.ProvAuditingMapper;
import com.wpzf.zxhc.mapper.WpCjDkxxbxj2023DTOMapper;
import com.wpzf.zxhc.mapper.WpCjTbhcjgSjMapper;
import com.wpzf.zxhc.service.*;
import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import shade.okhttp3.OkHttpClient;
import shade.okhttp3.Request;
import shade.okhttp3.Response;

import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.*;
import java.util.concurrent.ScheduledExecutorService;

//省级审核
@RestController
@RequestMapping("/sjsh")
public class ProvAuditingController {

    @Value("${tempath}")
    public String tempath;

    @Autowired
    ProvAuditingMapper provAuditingMapper;

    @Autowired
    private SqlSessionFactory sqlSessionFactory;

    @Autowired
    ProvAuditingService provAuditingService;

    @Autowired
    XjtbTbBaseService xjtbTbBaseService;

    @Autowired
    WpzfTbBaseService wpzfTbBaseService;

    @Autowired
    TokenService tokenService;

    @Autowired
    CommonSjService commonSjService;

    @Autowired
    AppService appService;

    @Autowired
    private ScheduledExecutorService scheduledExecutorService;

    @Autowired
    private DkShCityService dkShCityService;

    @Autowired
    WpCjTbhcjgSjMapper wpCjTbhcjgSjMapper;

    @RequestMapping(value = "/getPch", method = RequestMethod.POST)
    public AjaxResult getPch(@RequestBody Map<String, Object> parm) {
        try {
            List<Map> list = provAuditingService.getPch(parm);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getshibyPch", method = RequestMethod.POST)
    public AjaxResult getshibyPch(@RequestBody Map<String, Object> parm) {
        try {
            List<Map> list = provAuditingService.getshibyPch(parm);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getxianbyPch", method = RequestMethod.POST)
    public AjaxResult getxianbyPch(@RequestBody Map<String, Object> parm) {
        try {

            List<Map> list = provAuditingService.getxianbyPch(parm);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getAuditingInfo", method = RequestMethod.POST)
    public AjaxResult getAuditingInfo(@RequestBody Map<String, Object> parm) {
        try {
            List<ProvAuditingInfo> list = provAuditingService.getAuditingInfo(parm);
            int total = provAuditingService.getAuditingInfoCount(parm);
            return AjaxResult.success("获取成功", list, total);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getDkDetailByXzq", method = RequestMethod.POST)
    public AjaxResult getDkDetailByXzq(@RequestBody Map<String, Object> parm) {
        try {
            List<Map> list = provAuditingService.getDkDetailByXzq(parm);
            int total = provAuditingService.getDkDetailByXzqCount(parm);
            return AjaxResult.success("获取成功", list, total);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getDkDetailAllByXzq", method = RequestMethod.POST)
    public AjaxResult getDkDetailAllByXzq(@RequestBody Map<String, Object> parm) {
        try {
            List<Map> list = provAuditingService.getDkDetailAllByXzq(parm);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    //
    @RequestMapping(value = "/getDkHcInfo", method = RequestMethod.POST)
    public AjaxResult getDkHcInfo(@RequestBody Map<String, Object> parm) {
        String jcbh = parm.get("tbbh") + "";
        if (jcbh.indexOf(",") != -1) {
            String dkbh1 = jcbh.split(",")[0];
            parm.put("jcbh", dkbh1.split("-")[0]);
            parm.replace("tbbh", dkbh1.split("-")[0]);
            parm.put("dkbh", jcbh);
        } else {
            parm.put("jcbh", jcbh.split("-")[0]);
            parm.replace("tbbh", jcbh.split("-")[0]);
            parm.put("dkbh", jcbh);
        }
        try {
            //modelMap
            ModelMap modelMap = xjtbTbBaseService.getShowImgs(parm);//jcbh-xzqdm-pch
            //地块信息
            WpCjDkxxbxj2023DTO dkxxbxj2023DTO = provAuditingService.getDkInfoByDkbh(parm);//dkbh-pch
            //关联地块信息
            List<WpCjDkxxbxj2023DTO> dkxxbxj2023DTOList = provAuditingService.getRelationDkInfoByJcbh(parm);//jcbh-pch
            //核查结果
            WpCjTbhcjgSj2023 wpCjTbhcjgSj2023 = provAuditingService.getTbHcJgInfo(parm);//tbbh-pch
            //图斑示意图
            List<WpCjTbjt2023DTO> wpCjTbjt2023DTOS = wpzfTbBaseService.querytbjtBytbbh(parm);//tbbh-xzqdm-pch
            //图斑信息
            List<WpCjTbxxbxj2023DTO> tbxxbxj2023DTOS = provAuditingService.getTbInfoByJcbh(parm);//jcbh-pch

            Map<String, Object> map = new HashMap<>();
            map.put("modelMap", modelMap);
            map.put("wpCjDkxxb2023dto", dkxxbxj2023DTO);
            map.put("wpCjDkxxb2023relatedto", dkxxbxj2023DTOList);
            map.put("wpCjTbhcjg2023DTOS", wpCjTbhcjgSj2023);
            map.put("wpCjTbjt2023DTOS", wpCjTbjt2023DTOS);
            map.put("wpCjTbxxb2023DTOS", tbxxbxj2023DTOS);
            return AjaxResult.success("获取成功", map);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    /*保存核查结果*/
    @RequestMapping(value = "/addHcjgSj", method = RequestMethod.POST)
    public AjaxResult addHcjgSj(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        List<Map> list = new ArrayList<>();
        String selectList = parm.get("listParams").toString();
        int rest = 0;
        String ywhj = parm.get("ywhj") + "";
        if (!selectList.equals("") && !selectList.equals("null") && selectList != null) {
            JSONObject obj = JSON.parseObject(selectList);
            if (obj != null) {

                parm.put("username", loginUser.getUsername());
                // parm.put("xzqdm", obj.get("xzqdm"));
                // parm.put("pdlx",obj.get("pdlx"));
                parm.put("pch", obj.get("pch"));

                //parm.put("xzqdm", obj.get("xzqdm"));
                parm.put("shr", loginUser.getSysUser().getNickName());
                parm.put("sfhc", "是");

                parm.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
                String strPdlx = parm.get("pdlx") + "";
                if (strPdlx.equals("合法")) {
                    parm.put("jl_jlpf", parm.get("hf_jlJlpf"));
                } else if (strPdlx.equals("违法")) {
                    parm.put("jl_jlpf", parm.get("wf_jlJlpf"));
                } else if (strPdlx.equals("其他")) {
                    parm.put("jl_jlpf", parm.get("qt_jlJlpf"));
                }

                String state = parm.get("state") + "";
                Map<String, Object> item = commonSjService.queryHcJgById(parm);
                if (item != null) {
                    commonSjService.deleteHcJg(parm);
                    commonSjService.deleteHcjg_hf_dtPwwj(parm);
                    commonSjService.deleteHcjg_wf_wfpzwh(parm);
                    commonSjService.deleteHcjg_wf_wftgzmwj(parm);
                    commonSjService.deleteHcjg_qt_qtpzwh(parm);
                    commonSjService.deleteHcjg_qt_qtsftgxxydss(parm);
                    commonSjService.deleteHcjg_qt_qtsfzygd(parm);
                }
                rest = commonSjService.addHcjg(parm);
                String domains = parm.get("domains") + "";
                if (!domains.equals("[]") && !domains.equals("null") && domains != "null") {
                    JSONArray arraylist = JSONObject.parseArray(domains);
                    for (int i = 0; i < arraylist.size(); i++) { //遍历输出
                        JSONObject jsonObject = arraylist.getJSONObject(i);
                        String domainType = jsonObject.getString("domainType");
                        if (domainType.equals("domains")) {
                            ModelMap map = new ModelMap();
                            map.put("tbbh", parm.get("tbbh"));
                            map.put("xzqdm", parm.get("xzqdm"));
                            map.put("pch", parm.get("pch"));
                            map.put("sort", jsonObject.getString("key"));
                            map.put("hf_zlpwlx1", jsonObject.getString("hfZlpwlx1"));
                            map.put("hf_pzwh", jsonObject.getString("hfPzwh"));
                            map.put("hf_pzxmmc", jsonObject.getString("hfPzxmmc"));
                            map.put("hf_pzzygdmj", jsonObject.getString("hfPzzygdmj"));
                            map.put("hf_pzzygdmjdw", jsonObject.getString("hfPzzygdmjdw"));
                            map.put("hf_pzsj", jsonObject.getString("hfPzsj"));
                            map.put("hf_zlpwlx2", jsonObject.getString("hfZlpwlx2"));
                            map.put("hf_zlpwclmc", jsonObject.getString("hfZlpwclmc"));
                            map.put("ywhj", parm.get("ywhj"));
                            map.put("status", "");
                            int hf_rest = commonSjService.addHcjg_hf_DtPwwj(map);
                        } else if (domainType.equals("wfpzwh_domains")) {
                            ModelMap map = new ModelMap();
                            map.put("tbbh", parm.get("tbbh"));
                            map.put("xzqdm", parm.get("xzqdm"));
                            map.put("pch", parm.get("pch"));
                            map.put("sort", jsonObject.getString("key"));
                            map.put("wf_pzwh", jsonObject.getString("wfPzwh"));
                            map.put("wf_pzxmmc", jsonObject.getString("wfPzxmmc"));
                            map.put("wf_pzsj", jsonObject.getString("wfPzsj"));
                            map.put("ywhj", parm.get("ywhj"));
                            map.put("status", "");
                            commonSjService.addHcjg_wf_wfpzwh(map);
                        } else if (domainType.equals("wftgzmwj_domains")) {
                            ModelMap map = new ModelMap();
                            map.put("tbbh", parm.get("tbbh"));
                            map.put("xzqdm", parm.get("xzqdm"));
                            map.put("pch", parm.get("pch"));
                            map.put("sort", jsonObject.getString("key"));
                            map.put("wf_zlpwlx1", jsonObject.getString("wfZlpwlx1"));
                            map.put("wf_pzwh", jsonObject.getString("wfPzwh"));
                            map.put("wf_pzxmmc", jsonObject.getString("wfPzxmmc"));
                            map.put("wf_pzzygdmj", jsonObject.getString("wfPzzygdmj"));
                            map.put("wf_pzzygdmjdw", jsonObject.getString("wfPzzygdmjdw"));
                            map.put("wf_pzsj", jsonObject.getString("wfPzsj"));
                            map.put("wf_zlpwlx2", jsonObject.getString("wfZlpwlx2"));
                            map.put("wf_zlpwclmc", jsonObject.getString("wfZlpwclmc"));
                            map.put("ywhj", parm.get("ywhj"));
                            map.put("status", "");
                            commonSjService.addHcjg_wf_wftgzmwj(map);
                        } else if (domainType.equals("qtpzwh_domains")) {
                            ModelMap qtpzwh_map = new ModelMap();
                            qtpzwh_map.put("tbbh", parm.get("tbbh"));
                            qtpzwh_map.put("xzqdm", parm.get("xzqdm"));
                            qtpzwh_map.put("pch", parm.get("pch"));
                            qtpzwh_map.put("sort", jsonObject.getString("key"));
                            qtpzwh_map.put("qt_pzwh", jsonObject.getString("qtPzwh"));
                            qtpzwh_map.put("qt_pzxmmc", jsonObject.getString("qtPzxmmc"));
                            qtpzwh_map.put("qt_pzsj", jsonObject.getString("qtPzsj"));
                            qtpzwh_map.put("ywhj", parm.get("ywhj"));
                            qtpzwh_map.put("status", "");
                            rest = commonSjService.adddHcjg_qt_qtpzwh(qtpzwh_map);
                        } else if (domainType.equals("qtsftgxxydss_domains")) {
                            ModelMap qtsfzygd_map = new ModelMap();
                            qtsfzygd_map.put("tbbh", parm.get("tbbh"));
                            qtsfzygd_map.put("xzqdm", parm.get("xzqdm"));
                            qtsfzygd_map.put("pch", parm.get("pch"));
                            qtsfzygd_map.put("sort", jsonObject.getString("key"));
                            qtsfzygd_map.put("qt_tgbawjsj", jsonObject.getString("qtTgbawjsj"));
                            qtsfzygd_map.put("qt_clmc", jsonObject.getString("qtClmc"));
                            qtsfzygd_map.put("ywhj", parm.get("ywhj"));
                            qtsfzygd_map.put("status", "");
                            rest = commonSjService.addHcjg_qt_qtsfzygd(qtsfzygd_map);
                        } else if (domainType.equals("qtsfzygd_domains")) {
                            ModelMap qtsftgxxydss_map = new ModelMap();
                            qtsftgxxydss_map.put("tbbh", parm.get("tbbh"));
                            qtsftgxxydss_map.put("xzqdm", parm.get("xzqdm"));
                            qtsftgxxydss_map.put("pch", parm.get("pch"));
                            qtsftgxxydss_map.put("sort", jsonObject.getString("key"));
                            qtsftgxxydss_map.put("qt_sftgxxydssclmc", jsonObject.getString("qtSftgxxydssclmc"));
                            qtsftgxxydss_map.put("qt_sftgxxydsspfsj", jsonObject.getString("qtSftgxxydsspfsj"));
                            qtsftgxxydss_map.put("ywhj", parm.get("ywhj"));
                            qtsftgxxydss_map.put("status", "");
                            rest = commonSjService.addHcjg_qt_qtsftgxxydss(qtsftgxxydss_map);
                        }
                    }
                }


                Map<String, Object> map = new HashMap<>();
                map.put("ids", parm.get("ids"));
                map.put("pch", parm.get("pch"));
                map.put("xzqdm", obj.getString("xzqdm"));
                list = provAuditingService.getDkDetailAllByIndex(map);

            }
            if (("合法").equals(parm.get("pdlx").toString())) {
                //按照业务环节值  获取核查结果说明
                if (parm.get("hf_zphlxjc") != "") {
                    Map<String, Object> tbhcjgsm = commonSjService.getHcjgsmBytbbh(parm);
                    if (tbhcjgsm != null) {
                        tbhcjgsm.put("username", loginUser.getUsername());
                        tbhcjgsm.put("ywhj", parm.get("ywhj") + "");
                        commonSjService.updateHcjg_hcjgsm(tbhcjgsm);  //更新核查结果说明
                    }
                }
            } else if (("违法").equals(parm.get("pdlx").toString())) {
                //按照业务环节值  获取核查结果说明
                if (parm.get("wf_zphlxjc") != "") {
                    Map<String, Object> tbhcjgsm = commonSjService.getHcjgsmBytbbh(parm);
                    if (tbhcjgsm != null) {
                        tbhcjgsm.put("username", loginUser.getUsername());
                        tbhcjgsm.put("ywhj", parm.get("ywhj") + "");
                        commonSjService.updateHcjg_hcjgsm(tbhcjgsm);  //更新核查结果说明
                    }
                }
            } else if (("其他").equals(parm.get("pdlx").toString())) {
                //按照业务环节值  获取核查结果说明
                if (parm.get("qt_zphlxjc") != "") {
                    Map<String, Object> tbhcjgsm = commonSjService.getHcjgsmBytbbh(parm);
                    if (tbhcjgsm != null) {
                        tbhcjgsm.put("username", loginUser.getUsername());
                        tbhcjgsm.put("ywhj", parm.get("ywhj") + "");
                        commonSjService.updateHcjg_hcjgsm(tbhcjgsm);  //更新核查结果说明
                    }
                }
            }
        }

        return AjaxResult.success("添加核查结果", list, rest);
    }

    @RequestMapping(value = "/getDkDetailAllByIndex", method = RequestMethod.POST)
    public AjaxResult getDkDetailAllByIndex(@RequestBody Map<String, Object> parm) {
        try {
            List<Map> list = provAuditingService.getDkDetailAllByIndex(parm);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    //退回
    @RequestMapping(value = "/dkshSjSubmit", method = RequestMethod.POST)
    public AjaxResult dkshSjSubmit(@RequestBody Map<String, Object> parm) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            parm.put("czr", loginUser.getUsername());
            parm.put("realname", loginUser.getSysUser().getNickName());
            Integer nCount = provAuditingService.dkshSjSubmit(parm); //状态修改
            if (nCount == -1) {
                return AjaxResult.success("该区县存在未审核地块，无法进行提交", nCount);
            }
            return AjaxResult.success("退回成功", nCount);
        } catch (Exception ex) {
            return AjaxResult.error("退回失败", ex.toString());
        }
    }


    //提交 按照行政区划修改
    @RequestMapping(value = "/dkshDgSubmit", method = RequestMethod.POST)
    public AjaxResult dkshDgSubmit(@RequestBody Map<String, Object> parm) {
        try {

            Integer nCount = provAuditingService.dkshDgSubmit(parm);
            if (nCount == -1) {
                return AjaxResult.success("该区县存在未审核地块，无法进行提交", nCount);
            }
            return AjaxResult.success("提交成功", nCount);
        } catch (Exception ex) {
            return AjaxResult.error("提交失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getDkHcZzJgInfo", method = RequestMethod.POST)
    public AjaxResult getDkHcZzJgInfo(@RequestBody Map<String, Object> parm) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            parm.put("xzqdm", loginUser.getSysUser().getXzqdm());
            List<Map> list = provAuditingService.getDkHcZzJgInfo(parm);
            Integer total = provAuditingService.getDkHcZzJgInfoCount(parm);
            return AjaxResult.success("获取成功", list, total);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getDkHcZzJgPch", method = RequestMethod.GET)
    public AjaxResult getDkHcZzJgPch() {
        try {
//            Map parm = new HashMap();
//            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
//            parm.put("xzqdm", loginUser.getSysUser().getXzqdm());
//            List<Map> list = provAuditingService.getDkHcZzJgPch(parm);
            return AjaxResult.success("获取成功", new ArrayList<>());
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getDkHcJgByXzq", method = RequestMethod.POST)
    public AjaxResult getDkHcJgByXzq(@RequestBody Map<String, Object> parm) {
        try {
            List<Map> list = provAuditingService.getDkHcJgByXzq(parm);
            Integer total = provAuditingService.getDkHcJgByXzqCount(parm);
            return AjaxResult.success("获取成功", list, total);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getBtgDkJgAll", method = RequestMethod.POST)
    public AjaxResult getBtgDkJgAll(@RequestBody Map<String, Object> parm) {
        try {
            String xzqdm = parm.get("xzqdm").toString();
            if (xzqdm.equals("")) {
                LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
                parm.put("xzqdm", loginUser.getSysUser().getXzqdm());
            }
            List<Map> list = provAuditingService.getBtgDkJgAll(parm);
            Integer total = provAuditingService.getBtgDkJgAllCount(parm);
            return AjaxResult.success("获取成功", list, total);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getBtgDkPch", method = RequestMethod.GET)
    public AjaxResult getBtgDkPch() {
        try {
            Map parm = new HashMap();
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            parm.put("xzqdm", loginUser.getSysUser().getXzqdm());
            List<Map> list = provAuditingService.getBtgDkPch(parm);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getBtgDkXzqh", method = RequestMethod.POST)
    public AjaxResult getBtgDkXzqh(@RequestBody Map<String, Object> parm) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            parm.put("xzqdm", loginUser.getSysUser().getXzqdm());
            List<Map> list = provAuditingService.getBtgDkXzqh(parm);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getBtgDkList", method = RequestMethod.POST)
    public AjaxResult getBtgDkList(@RequestBody Map<String, Object> parm) {
        try {
            String xzqdm = parm.get("xzqdm").toString();
            if (xzqdm.equals("") || xzqdm == null) {
                LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
                parm.replace("xzqdm", loginUser.getSysUser().getXzqdm());
            }
            List<Map> list = provAuditingService.getBtgDkList(parm);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getBtgDkJgAllByIndex", method = RequestMethod.POST)
    public AjaxResult getBtgDkJgAllByIndex(@RequestBody Map<String, Object> parm) {
        try {
            String xzqdm = parm.get("xzqdm").toString();
            if (xzqdm.equals("") || xzqdm == null) {
                LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
                parm.replace("xzqdm", loginUser.getSysUser().getXzqdm());
            }
            List<Map> list = provAuditingService.getBtgDkJgAllByIndex(parm);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getBtgDkHcInfo", method = RequestMethod.POST)
    public AjaxResult getBtgDkHcInfo(@RequestBody Map<String, Object> parm) {
        String jcbh = parm.get("tbbh") + "";
        if (jcbh.indexOf(",") != -1) {
            String dkbh1 = jcbh.split(",")[0];
            parm.put("jcbh", dkbh1.split("-")[0]);
            parm.replace("tbbh", dkbh1.split("-")[0]);
            parm.put("dkbh", jcbh);
        } else {
            parm.put("jcbh", jcbh.split("-")[0]);
            parm.replace("tbbh", jcbh.split("-")[0]);
            parm.put("dkbh", jcbh);
        }
        try {
            //modelMap
            ModelMap modelMap = xjtbTbBaseService.getShowImgs(parm);//jcbh-xzqdm-pch
            //地块信息
            WpCjDkxxbxj2023DTO dkxxbxj2023DTO = provAuditingService.getBtgDkInfoByDkbh(parm);//dkbh-pch
            //关联地块信息
            List<WpCjDkxxbxj2023DTO> dkxxbxj2023DTOList = provAuditingService.getBtgRelationDkInfoByJcbh(parm);//jcbh-pch
            //核查结果
            WpCjTbhcjgSj2023 wpCjTbhcjgSj2023 = provAuditingService.getTbHcJgInfo(parm);//tbbh-pch
            //图斑示意图
            List<WpCjTbjt2023DTO> wpCjTbjt2023DTOS = wpzfTbBaseService.querytbjtBytbbh(parm);//tbbh-xzqdm-pch
            //图斑信息
            List<WpCjTbxxbxj2023DTO> tbxxbxj2023DTOS = provAuditingService.getTbInfoByJcbh(parm);//jcbh-pch

            Map<String, Object> map = new HashMap<>();
            map.put("modelMap", modelMap);
            map.put("wpCjDkxxb2023dto", dkxxbxj2023DTO);
            map.put("wpCjDkxxb2023relatedto", dkxxbxj2023DTOList);
            map.put("wpCjTbhcjg2023DTOS", wpCjTbhcjgSj2023);
            map.put("wpCjTbjt2023DTOS", wpCjTbjt2023DTOS);
            map.put("wpCjTbxxb2023DTOS", tbxxbxj2023DTOS);
            return AjaxResult.success("获取成功", map);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    /*保存核查结果*/
    @RequestMapping(value = "/addBtgHcjgSj", method = RequestMethod.POST)
    public AjaxResult addBtgHcjgSj(@RequestBody Map<String, Object> parm) {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        List<Map> list = new ArrayList<>();
        String selectList = parm.get("listParams").toString();
        int rest = 0;
        String ywhj = parm.get("ywhj") + "";
        if (!selectList.equals("") && !selectList.equals("null") && selectList != null) {
            JSONObject obj = JSON.parseObject(selectList);
            if (obj != null) {

                parm.put("username", loginUser.getUsername());
                // parm.put("xzqdm", obj.get("xzqdm"));
                // parm.put("pdlx",obj.get("pdlx"));
                parm.put("pch", obj.get("pch"));

                //parm.put("xzqdm", obj.get("xzqdm"));
                parm.put("shr", loginUser.getSysUser().getNickName());
                parm.put("sfhc", "是");

                parm.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
                String strPdlx = parm.get("pdlx") + "";
                if (strPdlx.equals("合法")) {
                    parm.put("jl_jlpf", parm.get("hf_jlJlpf"));
                } else if (strPdlx.equals("违法")) {
                    parm.put("jl_jlpf", parm.get("wf_jlJlpf"));
                } else if (strPdlx.equals("其他")) {
                    parm.put("jl_jlpf", parm.get("qt_jlJlpf"));
                }

                String state = parm.get("state") + "";
                Map<String, Object> item = commonSjService.queryHcJgById(parm);
                if (item != null) {
                    commonSjService.deleteHcJg(parm);
                    commonSjService.deleteHcjg_hf_dtPwwj(parm);
                    commonSjService.deleteHcjg_wf_wfpzwh(parm);
                    commonSjService.deleteHcjg_wf_wftgzmwj(parm);
                    commonSjService.deleteHcjg_qt_qtpzwh(parm);
                    commonSjService.deleteHcjg_qt_qtsftgxxydss(parm);
                    commonSjService.deleteHcjg_qt_qtsfzygd(parm);
                }
                rest = commonSjService.addHcjg(parm);
                String domains = parm.get("domains") + "";
                if (!domains.equals("[]") && !domains.equals("null") && domains != "null") {
                    JSONArray arraylist = JSONObject.parseArray(domains);
                    for (int i = 0; i < arraylist.size(); i++) { //遍历输出
                        JSONObject jsonObject = arraylist.getJSONObject(i);
                        String domainType = jsonObject.getString("domainType");
                        if (domainType.equals("domains")) {
                            ModelMap map = new ModelMap();
                            map.put("tbbh", parm.get("tbbh"));
                            map.put("xzqdm", parm.get("xzqdm"));
                            map.put("pch", parm.get("pch"));
                            map.put("sort", jsonObject.getString("key"));
                            map.put("hf_zlpwlx1", jsonObject.getString("hfZlpwlx1"));
                            map.put("hf_pzwh", jsonObject.getString("hfPzwh"));
                            map.put("hf_pzxmmc", jsonObject.getString("hfPzxmmc"));
                            map.put("hf_pzzygdmj", jsonObject.getString("hfPzzygdmj"));
                            map.put("hf_pzzygdmjdw", jsonObject.getString("hfPzzygdmjdw"));
                            map.put("hf_pzsj", jsonObject.getString("hfPzsj"));
                            map.put("hf_zlpwlx2", jsonObject.getString("hfZlpwlx2"));
                            map.put("hf_zlpwclmc", jsonObject.getString("hfZlpwclmc"));
                            map.put("ywhj", parm.get("ywhj"));
                            map.put("status", "");
                            int hf_rest = commonSjService.addHcjg_hf_DtPwwj(map);
                        } else if (domainType.equals("wfpzwh_domains")) {
                            ModelMap map = new ModelMap();
                            map.put("tbbh", parm.get("tbbh"));
                            map.put("xzqdm", parm.get("xzqdm"));
                            map.put("pch", parm.get("pch"));
                            map.put("sort", jsonObject.getString("key"));
                            map.put("wf_pzwh", jsonObject.getString("wfPzwh"));
                            map.put("wf_pzxmmc", jsonObject.getString("wfPzxmmc"));
                            map.put("wf_pzsj", jsonObject.getString("wfPzsj"));
                            map.put("ywhj", parm.get("ywhj"));
                            map.put("status", "");
                            commonSjService.addHcjg_wf_wfpzwh(map);
                        } else if (domainType.equals("wftgzmwj_domains")) {
                            ModelMap map = new ModelMap();
                            map.put("tbbh", parm.get("tbbh"));
                            map.put("xzqdm", parm.get("xzqdm"));
                            map.put("pch", parm.get("pch"));
                            map.put("sort", jsonObject.getString("key"));
                            map.put("wf_zlpwlx1", jsonObject.getString("wfZlpwlx1"));
                            map.put("wf_pzwh", jsonObject.getString("wfPzwh"));
                            map.put("wf_pzxmmc", jsonObject.getString("wfPzxmmc"));
                            map.put("wf_pzzygdmj", jsonObject.getString("wfPzzygdmj"));
                            map.put("wf_pzzygdmjdw", jsonObject.getString("wfPzzygdmjdw"));
                            map.put("wf_pzsj", jsonObject.getString("wfPzsj"));
                            map.put("wf_zlpwlx2", jsonObject.getString("wfZlpwlx2"));
                            map.put("wf_zlpwclmc", jsonObject.getString("wfZlpwclmc"));
                            map.put("ywhj", parm.get("ywhj"));
                            map.put("status", "");
                            commonSjService.addHcjg_wf_wftgzmwj(map);
                        } else if (domainType.equals("qtpzwh_domains")) {
                            ModelMap qtpzwh_map = new ModelMap();
                            qtpzwh_map.put("tbbh", parm.get("tbbh"));
                            qtpzwh_map.put("xzqdm", parm.get("xzqdm"));
                            qtpzwh_map.put("pch", parm.get("pch"));
                            qtpzwh_map.put("sort", jsonObject.getString("key"));
                            qtpzwh_map.put("qt_pzwh", jsonObject.getString("qtPzwh"));
                            qtpzwh_map.put("qt_pzxmmc", jsonObject.getString("qtPzxmmc"));
                            qtpzwh_map.put("qt_pzsj", jsonObject.getString("qtPzsj"));
                            qtpzwh_map.put("ywhj", parm.get("ywhj"));
                            qtpzwh_map.put("status", "");
                            rest = commonSjService.adddHcjg_qt_qtpzwh(qtpzwh_map);
                        } else if (domainType.equals("qtsftgxxydss_domains")) {
                            ModelMap qtsfzygd_map = new ModelMap();
                            qtsfzygd_map.put("tbbh", parm.get("tbbh"));
                            qtsfzygd_map.put("xzqdm", parm.get("xzqdm"));
                            qtsfzygd_map.put("pch", parm.get("pch"));
                            qtsfzygd_map.put("sort", jsonObject.getString("key"));
                            qtsfzygd_map.put("qt_tgbawjsj", jsonObject.getString("qtTgbawjsj"));
                            qtsfzygd_map.put("qt_clmc", jsonObject.getString("qtClmc"));
                            qtsfzygd_map.put("ywhj", parm.get("ywhj"));
                            qtsfzygd_map.put("status", "");
                            rest = commonSjService.addHcjg_qt_qtsfzygd(qtsfzygd_map);
                        } else if (domainType.equals("qtsfzygd_domains")) {
                            ModelMap qtsftgxxydss_map = new ModelMap();
                            qtsftgxxydss_map.put("tbbh", parm.get("tbbh"));
                            qtsftgxxydss_map.put("xzqdm", parm.get("xzqdm"));
                            qtsftgxxydss_map.put("pch", parm.get("pch"));
                            qtsftgxxydss_map.put("sort", jsonObject.getString("key"));
                            qtsftgxxydss_map.put("qt_sftgxxydssclmc", jsonObject.getString("qtSftgxxydssclmc"));
                            qtsftgxxydss_map.put("qt_sftgxxydsspfsj", jsonObject.getString("qtSftgxxydsspfsj"));
                            qtsftgxxydss_map.put("ywhj", parm.get("ywhj"));
                            qtsftgxxydss_map.put("status", "");
                            rest = commonSjService.addHcjg_qt_qtsftgxxydss(qtsftgxxydss_map);
                        }
                    }
                }
                Map<String, Object> map = new HashMap<>();
                map.put("ids", parm.get("ids"));
                map.put("pch", parm.get("pch"));
                map.put("xzqdm", obj.getString("xzqdm"));
                list = provAuditingService.getBtgDkJgAllByIndex(map);

            }
        }
        //按照业务环节值  获取核查结果说明
        if (("合法").equals(parm.get("pdlx").toString())) {
            //按照业务环节值  获取核查结果说明
            if (parm.get("hf_zphlxjc") != "") {
                Map<String, Object> tbhcjgsm = commonSjService.getHcjgsmBytbbh(parm);
                if (tbhcjgsm != null) {
                    tbhcjgsm.put("username", loginUser.getUsername());
                    tbhcjgsm.put("ywhj", parm.get("ywhj") + "");
                    commonSjService.updateHcjg_hcjgsm(tbhcjgsm);  //更新核查结果说明
                }
            }
        } else if (("违法").equals(parm.get("pdlx").toString())) {
            //按照业务环节值  获取核查结果说明
            if (parm.get("wf_zphlxjc") != "") {
                Map<String, Object> tbhcjgsm = commonSjService.getHcjgsmBytbbh(parm);
                if (tbhcjgsm != null) {
                    tbhcjgsm.put("username", loginUser.getUsername());
                    tbhcjgsm.put("ywhj", parm.get("ywhj") + "");
                    commonSjService.updateHcjg_hcjgsm(tbhcjgsm);  //更新核查结果说明
                }
            }
        } else if (("其他").equals(parm.get("pdlx").toString())) {
            //按照业务环节值  获取核查结果说明
            if (parm.get("qt_zphlxjc") != "") {
                Map<String, Object> tbhcjgsm = commonSjService.getHcjgsmBytbbh(parm);
                if (tbhcjgsm != null) {
                    tbhcjgsm.put("username", loginUser.getUsername());
                    tbhcjgsm.put("ywhj", parm.get("ywhj") + "");
                    commonSjService.updateHcjg_hcjgsm(tbhcjgsm);  //更新核查结果说明
                }
            }
        }
        return AjaxResult.success("添加核查结果", list, rest);
    }

    @RequestMapping(value = "/btgDkshSjSubmit", method = RequestMethod.POST)
    public AjaxResult btgDkshSjSubmit(@RequestBody Map<String, Object> parm) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            parm.put("username", loginUser.getUsername());
            Integer nCount = provAuditingService.btgDkshSjSubmit(parm);
            if (nCount == -1) {
                return AjaxResult.success("该区县存在未审核地块，无法进行提交", nCount);
            }
            return AjaxResult.success("提交成功", nCount);
        } catch (Exception ex) {
            return AjaxResult.error("提交失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getProvExtractionrecordYear", method = RequestMethod.POST)
    public AjaxResult getProvExtractionrecordYear(@RequestBody Map<String, Object> parm) {
        try {
            List<Map> list = provAuditingService.getProvExtractionrecordYear(parm);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getProvExtractionrecordPc", method = RequestMethod.POST)
    public AjaxResult getProvExtractionrecordPc(@RequestBody Map<String, Object> parm) {
        try {
            List<Map> list = provAuditingService.getProvExtractionrecordPc(parm);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getProvExtractionrecord", method = RequestMethod.POST)
    public AjaxResult getProvExtractionrecord(@RequestBody Map<String, Object> parm) {
        try {
            List<Map> list = provAuditingService.getProvExtractionrecord(parm);
            Integer total = provAuditingService.getProvExtractionrecordCount(parm);
            return AjaxResult.success("获取成功", list, total);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getProvExtractionData", method = RequestMethod.POST)
    public AjaxResult getProvExtractionData(@RequestBody Map<String, Object> parm) {
        try {
            List<Map> list = provAuditingService.getProvExtractionData(parm);
            Integer total = provAuditingService.getProvExtractionDataCount(parm);
            return AjaxResult.success("获取成功", list, total);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getProvExtractionDatasmc1", method = RequestMethod.POST)
    public AjaxResult getProvExtractionDatasmc1(@RequestBody Map<String, Object> parm) {
        try {
            List<Map> list = provAuditingService.getProvExtractionDatasmc1(parm);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getWyname", method = RequestMethod.POST)
    public AjaxResult getWyname(@RequestBody Map<String, Object> parm) {
        try {
            if (parm.get("xzqdm").toString() != "") {
                parm.replace("xzqdm", parm.get("xzqdm").toString().substring(0, 2));
            }
            List<String> list = provAuditingService.getWyname(parm);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    @RequestMapping(value = "/getProvExtractionDataqxmc", method = RequestMethod.POST)
    public AjaxResult getProvExtractionDataqxmc(@RequestBody Map<String, Object> parm) {
        try {
            List<Map> list = provAuditingService.getProvExtractionDataqxmc(parm);
            return AjaxResult.success("获取成功", list);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    /*数据导入*/
    @Log(title = "数据导入", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/uploadFileZip", method = RequestMethod.POST)
    public AjaxResult uploadFileZip(MultipartFile file, String year, String pc, String name, String radio, String xzqdm) {
        try {
            //获得文件名称
            String fileName = file.getOriginalFilename();

            //获得文件后缀名
            String type = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();

            //判断上传的是否是压缩包
            if (!type.equals("zip") && !type.equals("rar")) {
                return AjaxResult.error("请上传文件压缩包");
            }
            //上传唯一值
            String bsm = UUID.randomUUID().toString().replace("-", "");
            WpCjdataUploadDTO task = new WpCjdataUploadDTO();
            task.czr = SecurityUtils.getUsername();
            task.czdate = new Date();
            task.id = bsm;
            task.taskname = name;
            task.iswyname = radio;
            task.year = year;
            task.pc = pc;
            task.xzqdm = xzqdm;
            List<WpCjdataUploadDTO> models = new ArrayList<WpCjdataUploadDTO>();


            String sFilePath = provAuditingService.uploadFile(file); //上传文件
            if (sFilePath != "") {
                task.filepath = sFilePath;
                String res = provAuditingService.importDataByshp(sFilePath, bsm);
                if (res.equals("")) {
                    task.status = "导入成功";
                    models.add(task);
                    InsertBatch(models);
                    return AjaxResult.success("数据导入成功");
                } else {
                    task.status = "导入失败," + res;
                    models.add(task);
                    InsertBatch(models);
                    return AjaxResult.error("数据导入失败", res);
                }
            }

        } catch (Exception ex) {
            return AjaxResult.error("数据导入失败", ex.toString());
        }
        return AjaxResult.error("数据导入失败");
    }

    @Transactional
    public boolean InsertBatch(List<WpCjdataUploadDTO> models) {
        SqlSession sqlSession = null;
        try {
            //使用批处理
            sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
            DataUploadMapper dataUploadMapper = sqlSession.getMapper(DataUploadMapper.class);
            models.stream().forEach(datauploadDao -> dataUploadMapper.insert(datauploadDao));
            sqlSession.commit();
            return true;
        } catch (Exception ex) {
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            ex.printStackTrace();
            return false;
        } finally {
            // 确保SqlSession被关闭
            if (sqlSession != null) {
                sqlSession.close();
            }
        }
    }

    public String method(Object object) {
        String obj = object != null ? object.toString() : "";
        return obj;
    }

    //省级地块审核详情
    @RequestMapping(value = "/getShengShTaskInfo", method = RequestMethod.POST)
    public AjaxResult getShengShTaskInfo(@RequestBody Map<String, Object> parm) {
        String jcbh = parm.get("jcbh") + "";
        parm.put("tbbh", parm.get("dkbh"));
        if (jcbh.indexOf(",") != -1) {
            parm.put("jcbh", jcbh.split("-")[0]);
        }
        try {
            WpCjTbBaseinfosjDTO wpcjTbBaseinfosjDTO = new WpCjTbBaseinfosjDTO();
            List<WpCjDkpw2023DTO> lists = new ArrayList<>();
            //获取地块信息  dkxxbxj2023DTOS
            WpCjDkxxbxj2023DTO wpcjDkxxb2023DTO = dkShCityService.getDkInfoByDkbh(parm);
            wpcjTbBaseinfosjDTO.setWpCjDkxxb2023dto(wpcjDkxxb2023DTO);

            //获取图斑信息 相关图斑全部查出
            List<WpCjTbxxbxj2023DTO> wpCjTbxxb2023DTOS = dkShCityService.getTbxxbxjByJcbhList(parm);
            wpcjTbBaseinfosjDTO.setWpCjTbxxb2023DTOS(wpCjTbxxb2023DTOS);


            //其他相关的拆分图斑
            List<WpCjDkxxbxj2023DTO> wpCjDkxxb2023relatedto = xjtbTbBaseService.queryWpCjDkInfoByJcbh(parm);
            /*if (wpCjDkxxb2023relatedto.size() > 0) {
                for (int i = 0; i < wpCjDkxxb2023relatedto.size(); i++) {
                    lists = new ArrayList<>();
                    WpCjDkxxbxj2023DTO model = wpCjDkxxb2023relatedto.get(i);

                    if (!("null").equals(model.getNydzypzwh()) && !("").equals(model.getNydzypzwh()) && model.getNydzypzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getNydzypzwh()).split(","); //批准文号
                        String[] pwlyarr = method(model.getNydzypwly()).split(",");
                        String[] pzmjarr = method(model.getNydzypzmj()).split(",");
                        String[] pzrqarr = method(model.getNydzypzrq()).split(",");

                        //江西没有
                        String[] tdgypwlxejlarr = method(model.getNydzytdgypwlxejl()).split(",");
                        String[] pwlbarr = method(model.getNydzypwlb()).split(",");
                        String[] pznydmjarr = method(model.getNydzypznydmj()).split(",");
                        String[] pzgdmjarr = method(model.getNydzypzgdmj()).split(",");
                        String[] pzyjjbntmjarr = method(model.getNydzypzyjjbntmj()).split(",");

                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("农用地转用");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "" && pzrqarr.length > j) {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "" && pwlyarr.length > j) {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "" && pzmjarr.length > j) {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "" && tdgypwlxejlarr.length > j) {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "" && pwlbarr.length > j) {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "" && pznydmjarr.length > j) {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "" && pzgdmjarr.length > j) {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "" && pzyjjbntmjarr.length > j) {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getZjggpzwh()) && !("").equals(model.getZjggpzwh()) && model.getZjggpzwh() != null) //增加挂钩批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getZjggpzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getZjggtdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getZjggpwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getZjggpzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getZjggpwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getZjggpzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getZjggpznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getZjggpzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getZjggpzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("增减挂钩");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "" && pzrqarr.length > j) {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "" && pwlyarr.length > j) {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "" && pzmjarr.length > j) {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "" && tdgypwlxejlarr.length > j) {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "" && pwlbarr.length > j) {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "" && pznydmjarr.length > j) {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "" && pzgdmjarr.length > j) {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "" && pzyjjbntmjarr.length > j) {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getGkfqdpzwh()) && !("").equals(model.getGkfqdpzwh()) && model.getGkfqdpzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getGkfqdpzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getGkfqdtdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getGkfqdpwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getGkfqdpzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getGkfqdpwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getGkfqdpzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getGkfqdpznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getGkfqdpzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getGkfqdpzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("工矿废弃地");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "" && pzrqarr.length > j) {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "" && pwlyarr.length > j) {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "" && pzmjarr.length > j) {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "" && tdgypwlxejlarr.length > j) {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "" && pwlbarr.length > j) {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "" && pznydmjarr.length > j) {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "" && pzgdmjarr.length > j) {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "" && pzyjjbntmjarr.length > j) {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getBdcqzspzwh()) && !("").equals(model.getBdcqzspzwh()) && model.getBdcqzspzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getBdcqzspzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getBdcqzstdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getBdcqzspwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getBdcqzspzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getBdcqzspwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getBdcqzspzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getBdcqzspznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getBdcqzspzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getBdcqzspzzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("不动产权证书");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "" && pzrqarr.length > j) {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "" && pwlyarr.length > j) {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "" && pzmjarr.length > j) {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "" && tdgypwlxejlarr.length > j) {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "" && pwlbarr.length > j) {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "" && pznydmjarr.length > j) {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "" && pzgdmjarr.length > j) {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "" && pzyjjbntmjarr.length > j) {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getSsnydpzwh()) && !("").equals(model.getSsnydpzwh()) && model.getSsnydpzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getSsnydpzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getSsnydtdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getSsnydpwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getSsnydpzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getSsnydpwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getSsnydpzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getSsnydpznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getSsnydpzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getSsnydpzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("设施农用地");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "" && pzrqarr.length > j) {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "" && pwlyarr.length > j) {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "" && pzmjarr.length > j) {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "" && tdgypwlxejlarr.length > j) {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "" && pwlbarr.length > j) {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "" && pznydmjarr.length > j) {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "" && pzgdmjarr.length > j) {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "" && pzyjjbntmjarr.length > j) {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getTdzzyspzwh()) && !("").equals(model.getTdzzyspzwh()) && model.getTdzzyspzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getTdzzyspzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getTdzzystdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getTdzzyspwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getTdzzyspzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getTdzzyspwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getTdzzyspzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getTdzzyspznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getTdzzyspzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getTdzzyspzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("土地整治验收");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "" && pzrqarr.length > j) {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "" && pwlyarr.length > j) {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "" && pzmjarr.length > j) {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "" && tdgypwlxejlarr.length > j) {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "" && pwlbarr.length > j) {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "" && pznydmjarr.length > j) {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "" && pzgdmjarr.length > j) {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "" && pzyjjbntmjarr.length > j) {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getLsydpzwh()) && !("").equals(model.getLsydpzwh()) && model.getLsydpzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getLsydpzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getLsydtdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getLsydpwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getLsydpzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getLsydpwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getLsydpzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getLsydpznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getLsydpzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getLsydpzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("临时用地");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "" && pzrqarr.length > j) {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "" && pwlyarr.length > j) {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "" && pzmjarr.length > j) {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "" && tdgypwlxejlarr.length > j) {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "" && pwlbarr.length > j) {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "" && pznydmjarr.length > j) {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "" && pzgdmjarr.length > j) {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "" && pzyjjbntmjarr.length > j) {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getTdgypzwh()) && !("").equals(model.getTdgypzwh()) && model.getTdgypzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getTdgypzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getTdgytdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getTdgypwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getTdgypzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getTdgypwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getTdgypzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getTdgypznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getTdgypzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getTdgypzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("土地供应");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "" && pzrqarr.length > j) {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "" && pwlyarr.length > j) {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "" && pzmjarr.length > j) {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "" && tdgypwlxejlarr.length > j) {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "" && pwlbarr.length > j) {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "" && pznydmjarr.length > j) {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "" && pzgdmjarr.length > j) {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "" && pzyjjbntmjarr.length > j) {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getXxydpzwh()) && !("").equals(model.getXxydpzwh()) && model.getXxydpzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getXxydpzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getXxydtdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getXxydpwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getXxydpzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getXxydpwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getXxydpzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getXxydpznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getXxydpzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getXxydpzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("先行用地");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "" && pzrqarr.length > j) {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "" && pwlyarr.length > j) {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "" && pzmjarr.length > j) {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "" && tdgypwlxejlarr.length > j) {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "" && pwlbarr.length > j) {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "" && pznydmjarr.length > j) {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "" && pzgdmjarr.length > j) {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "" && pzyjjbntmjarr.length > j) {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getYspzwh()) && !("").equals(model.getYspzwh()) && model.getYspzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getYspzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getYstdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getYspwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getYspzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getYspwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getYspzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getYspznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getYspzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getYspzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("预审");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "" && pzrqarr.length > j) {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "" && pwlyarr.length > j) {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "" && pzmjarr.length > j) {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "" && tdgypwlxejlarr.length > j) {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "" && pwlbarr.length > j) {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "" && pznydmjarr.length > j) {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "" && pzgdmjarr.length > j) {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "" && pzyjjbntmjarr.length > j) {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    if (!("null").equals(model.getQtpzwh()) && !("").equals(model.getQtpzwh()) && model.getQtpzwh() != null) //农转用批准文号 所有字段全部拆
                    {
                        String[] pzwharr = method(model.getQtpzwh()).split(","); //批准文号
                        String[] tdgypwlxejlarr = method(model.getQttdgypwlxejl()).split(",");//批准文号
                        String[] pwlbarr = method(model.getQtpwlb()).split(",");//批文类别
                        String[] pzrqarr = method(model.getQtpzrq()).split(",");//批准日期
                        String[] pwlyarr = method(model.getQtpwly()).split(",");//批文来源
                        String[] pzmjarr = method(model.getQtpzmj()).split(",");//批准面积
                        String[] pznydmjarr = method(model.getQtpznydmj()).split(",");//批准农用地面积
                        String[] pzgdmjarr = method(model.getQtpzgdmj()).split(",");//批准耕地面积
                        String[] pzyjjbntmjarr = method(model.getQtpzyjjbntmj()).split(",");//批准永久基本农田面积
                        if (pzwharr.length > 0 && pzwharr[0] != "") {
                            for (int j = 0; j < pzwharr.length; j++) {
                                WpCjDkpw2023DTO pw = new WpCjDkpw2023DTO();
                                pw.setHf_pwlx("其他");
                                pw.setHf_pzwh(pzwharr[j].toString());
                                if (pzrqarr.length > 0 && pzrqarr[0] != "" && pzrqarr.length > j) {
                                    pw.setHf_pzrq(pzrqarr[j].toString());
                                }
                                if (pwlyarr.length > 0 && pwlyarr[0] != "" && pwlyarr.length > j) {
                                    pw.setHf_pwly(pwlyarr[j].toString());
                                }
                                if (pzmjarr.length > 0 && pzmjarr[0] != "" && pzmjarr.length > j) {
                                    pw.setHf_pzmj(pzmjarr[j].toString());
                                }
                                if (tdgypwlxejlarr.length > 0 && tdgypwlxejlarr[0] != "" && tdgypwlxejlarr.length > j) {
                                    pw.setHf_tdgypwlxejl(tdgypwlxejlarr[j].toString());
                                }
                                if (pwlbarr.length > 0 && pwlbarr[0] != "" && pwlbarr.length > j) {
                                    pw.setHf_pwlb(pwlbarr[j].toString());
                                }
                                if (pznydmjarr.length > 0 && pznydmjarr[0] != "" && pznydmjarr.length > j) {
                                    pw.setHf_pznydmj(pznydmjarr[j].toString());
                                }
                                if (pzgdmjarr.length > 0 && pzgdmjarr[0] != "" && pzgdmjarr.length > j) {
                                    pw.setHf_pzgdmj(pzgdmjarr[j].toString());
                                }
                                if (pzyjjbntmjarr.length > 0 && pzyjjbntmjarr[0] != "" && pzyjjbntmjarr.length > j) {
                                    pw.setHf_pzyjjbntmj(pzyjjbntmjarr[j].toString());
                                }
                                lists.add(pw);
                            }

                        }
                    }
                    model.setHfpwlist(lists);
                }
            }*/
            wpcjTbBaseinfosjDTO.setWpCjDkxxb2023relatedto(wpCjDkxxb2023relatedto);


            //获取举证照片
            parm.put("sfzz", "自主提取".equals(wpCjTbxxb2023DTOS.get(0).getGjxfhzztq()) ? "1" : "0");
            WpCjGsinfoly2024DTO gsinfoly = xjtbTbBaseService.getGsinfoly(parm);

            wpcjTbBaseinfosjDTO.setWpCjGsinfoly2024DTO(gsinfoly);

            ModelMap modelMap = new ModelMap();
            if ("0".equals(gsinfoly.getInfoly())) {
                modelMap = xjtbTbBaseService.getShowImgsnew(parm);
            } else if ("1".equals(gsinfoly.getInfoly())) {
                List<String> list = new ArrayList<>();
                list.add(appService.getInfo(parm));
//                System.out.println(list);
                modelMap.put("data", list);
            }
            wpcjTbBaseinfosjDTO.setModelMap(modelMap);

            //获取图斑截图
            List<WpCjTbjt2023DTO> wpCjTbjt2023DTOS = xjtbTbBaseService.querytbjtBytbbhsheng1(parm);
            wpcjTbBaseinfosjDTO.setWpCjTbjt2023DTOS(wpCjTbjt2023DTOS);

            //获取市级审核信息
            WpCjTbhcjgshij2023 tbhcjgshijByDkbh = dkShCityService.getTbhcjgshijByDkbh(parm);
            wpcjTbBaseinfosjDTO.setWpCjTbhcjgshij2023(tbhcjgshijByDkbh);

            //获取省级审核信息
            WpCjTbhcjgshengj2023 tbhcjgshengjByDkbh = provAuditingService.getTbhcjgshengjByDkbh(parm);
            wpcjTbBaseinfosjDTO.setWpCjTbhcjgshengj2023(tbhcjgshengjByDkbh);


            return AjaxResult.success("获取成功", wpcjTbBaseinfosjDTO);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    //暂存
    @RequestMapping(value = "/saveShengTbjg", method = RequestMethod.POST)
    public AjaxResult saveShengTbjg(@RequestBody Map<String, Object> parm) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            parm.put("czr", loginUser.getUsername());
            parm.put("realname", loginUser.getSysUser().getNickName());
            parm.put("shr", loginUser.getSysUser().getNickName());
            parm.put("username", loginUser.getUsername());
            Integer rest = provAuditingService.saveShengTbjg(parm);
            return AjaxResult.success("保存 成功", rest);
        } catch (Exception ex) {
            return AjaxResult.error("保存 失败", ex.toString());
        }
    }

    //提交
    @RequestMapping(value = "/shengSubmit", method = RequestMethod.POST)
    public AjaxResult shengSubmit(@RequestBody Map<String, Object> parm) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            parm.put("czr", loginUser.getUsername());
            parm.put("shr", loginUser.getSysUser().getNickName());
            parm.put("username", loginUser.getUsername());

            Integer rest = provAuditingService.shengSubmit(parm);
            return AjaxResult.success("提交 成功", rest);
        } catch (Exception ex) {
            return AjaxResult.error("提交 失败", ex.toString());
        }
    }

    //退回
    @RequestMapping(value = "/shengThxg", method = RequestMethod.POST)
    public AjaxResult shengThxg(@RequestBody Map<String, Object> parm) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            parm.put("czr", loginUser.getUsername());
            parm.put("realname", loginUser.getSysUser().getNickName());
            parm.put("shr", loginUser.getSysUser().getNickName());
            parm.put("username", loginUser.getUsername());

            String sheng = parm.get("xzqdm").toString().substring(0, 2);//获取前2位
            parm.put("sheng", sheng);
            List<Map> list = provAuditingMapper.getInfoly(parm);
            String str = "智慧核查";
            if (list != null && list.size() > 0) {
                str = list.get(0).get("ly").toString();
                if (str.equals("0")) {
                    str = "国土云";
                }
            }
            Integer rest = 0;
            if (str.equals("国土云")) {
                //调用国土云接口  进行退回修改
                rest = provAuditingService.shengThxggty(parm);
            } else {
                rest = provAuditingService.shengThxg(parm);
            }
            if (rest > 0) {
                return AjaxResult.success("退回成功", rest);
            } else {
                return AjaxResult.success("退回失败", 0);
            }
        } catch (Exception ex) {
            return AjaxResult.success("退回失败", ex.toString());
        }
    }

    //获取合法信息
    @Log(title = "获取合法-核查结果", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/getHftgzmwj", method = RequestMethod.POST)
    AjaxResult getHftgzmwj(@RequestBody Map<String, Object> parms) {
        try {
            List<WpCjTbhcjgSjHftgzmwj2023> wpCjTbhcjgHftgzmwj2023DTOS = wpCjTbhcjgSjMapper.getTbhcjgSjHftgzmwjInfo(parms);
            return AjaxResult.success("获取成功", wpCjTbhcjgHftgzmwj2023DTOS);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    //获取违法证明文件
    @Log(title = "获取违法-证明文件", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/getWftgzmwj", method = RequestMethod.POST)
    AjaxResult getWftgzmwj(@RequestBody Map<String, Object> parms) {
        try {
            List<WpCjTbhcjgSjWftgzmwj2023> wpCjTbhcjgWftgzmwj2023DTO = wpCjTbhcjgSjMapper.getTbhcjgSjWftgzmwjInfo(parms);
            return AjaxResult.success("获取成功", wpCjTbhcjgWftgzmwj2023DTO);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    //获取违法批准文号
    @Log(title = "获取违法-批准文号", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/getWfpzwh", method = RequestMethod.POST)
    AjaxResult getWfpzwh(@RequestBody Map<String, Object> parms) {
        try {
            List<WpCjTbhcjgSjWfpzwh2023> wpCjTbhcjgWfpzwh2023DTO = wpCjTbhcjgSjMapper.getTbhcjgSjWfpzwhInfo(parms);
            return AjaxResult.success("获取成功", wpCjTbhcjgWfpzwh2023DTO);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    //获取其他批准文号
    @Log(title = "获取其他-批准文号", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/getQtpzwh", method = RequestMethod.POST)
    AjaxResult getQtpzwh(@RequestBody Map<String, Object> parms) {
        try {
            List<WpCjTbhcjgSjQtpzwh2023> rest = wpCjTbhcjgSjMapper.getTbhcjgSjQtpzwhInfo(parms);
            return AjaxResult.success("获取成功", rest);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    //获取其他是否占用耕地
    @Log(title = "获取其他-是否占用耕地", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/getQtsfzygd", method = RequestMethod.POST)
    AjaxResult getQtsfzygd(@RequestBody Map<String, Object> parms) {
        try {
            List<WpCjTbhcjgSjQtsfzygd2023> rest = wpCjTbhcjgSjMapper.getTbhcjgSjQtsfzygdInfo(parms);
            return AjaxResult.success("获取成功", rest);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    //获取其他提供先行用地手续
    @Log(title = "获取其他-提供先行用地手续", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/getQtsftgxxydss", method = RequestMethod.POST)
    AjaxResult getQtsftgxxydss(@RequestBody Map<String, Object> parms) {
        try {
            List<WpCjTbhcjgSjQtsftgxxydss2023> rest = wpCjTbhcjgSjMapper.getTbhcjgSjQtsftgxxydssInfo(parms);
            return AjaxResult.success("获取成功", rest);
        } catch (Exception ex) {
            return AjaxResult.error("获取失败", ex.toString());
        }
    }

    //获取附件信息
    @Log(title = "获取附件信息", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/queryFjInfo", method = RequestMethod.POST)
    public AjaxResult queryFjInfo(@RequestBody Map<String, Object> parms) {
        try {
            List<Map<String, Object>> rest = provAuditingService.queryFjInfo(parms);
            if (rest != null && rest.size() > 0) {
                for (int i = 0; i < rest.size(); i++) {
                    String fjUrl = rest.get(i).get("fjurl").toString();
                    rest.get(i).put("fjurl1", downloadFile(fjUrl, "preview"));
                }
            }
            return AjaxResult.success("获取附件信息 成功", rest);
        } catch (Exception ex) {
            return AjaxResult.error("获取附件信息 失败", ex.toString());
        }
    }

    public String downloadFile(String fileUrl, String action) throws Exception {
        OkHttpClient client = new OkHttpClient();

        Request.Builder requestBuilder = new Request.Builder().url(fileUrl);
        String fileName = fileUrl.substring(fileUrl.lastIndexOf('/') + 1);
        // 设置请求头
        if ("download".equals(action)) {
            requestBuilder.addHeader("Content-Disposition", "attachment; filename=pdf-file.pdf");
        } else {
            requestBuilder.addHeader("Content-Disposition", "inline; filename=pdf-file.pdf");
        }

        Request request = requestBuilder.build();
        Response response = client.newCall(request).execute();
        String saveFilePath = tempath + "\\" + fileName;  // 存储路径  // 存储路径
        if (response.isSuccessful()) {
            InputStream inputStream = response.body().byteStream();


            FileOutputStream outputStream = new FileOutputStream(saveFilePath);
            byte[] buffer = new byte[1024];
            int bytesRead;
            while ((bytesRead = inputStream.read(buffer)) != -1) {
                outputStream.write(buffer, 0, bytesRead);
            }

            outputStream.close();
            inputStream.close();
            return saveFilePath;
//        URL url = new URL(fileUrl);
//        HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
//        String file = url.getFile();
//        String fileName = file.substring(file.lastIndexOf('/') + 1);
//        // 设置请求头
//        if ("download".equals(action)) {
//            httpConn.setRequestProperty("Content-Disposition", "attachment; filename="+fileName);
//        } else {
//            httpConn.setRequestProperty("Content-Disposition", "inline; filename="+fileName);
//        }
//        httpConn.setConnectTimeout(3000);
//        // 限制输入流等待数据到达的时间，超时将会抛出java.net.SocketTimeoutException
//        httpConn.setReadTimeout(3000);
//        // 设定请求的方法为"POST"，默认是GET
//        httpConn.setRequestMethod("POST");
//        // 设置传送的内容类型是json格式
//        httpConn.setRequestProperty("Content-Type", "application/json;charset=utf-8");
//        // 接收的内容类型也是json格式
//        httpConn.setRequestProperty("Accept", "application/json;charset=utf-8");
//        // 设置是否从httpUrlConnection读入，默认情况下是true
//        httpConn.setDoInput(true);
//        // 由于URLConnection在默认的情况下不允许输出，所以在请求输出流之前必须调用setDoOutput(true)。为一个HTTP URL将doOutput设置为true时，请求方法将由GET变为POST
//        httpConn.setDoOutput(true);
//        // 是否使用缓存，Post方式不能使用缓存
//        httpConn.setUseCaches(false);
//
//        InputStream inputStream = httpConn.getInputStream();
//        String saveFilePath = tempath+"\\"+fileName;  // 存储路径
//
//        FileOutputStream outputStream = new FileOutputStream(saveFilePath);
//        BufferedInputStream bis = new BufferedInputStream(inputStream);
//        byte[] buffer = new byte[1024];
//        int bytesRead;
//        while ((bytesRead = bis.read(buffer)) != -1) {
//            outputStream.write(buffer, 0, bytesRead);
//        }
//
//        outputStream.close();
//        bis.close();
//        inputStream.close();
//        httpConn.disconnect();
//
//
        }
        return saveFilePath;
    }

    //保存退回原因
    @Log(title = "保存退回原因", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/saveThyy", method = RequestMethod.POST)
    public AjaxResult saveThyy(@RequestBody Map<String, Object> parms) {
        try {
            Integer rest = provAuditingService.saveThyy(parms);
            return AjaxResult.success("保存退回原因 成功", rest);
        } catch (Exception ex) {
            return AjaxResult.error("保存退回原因 失败", ex.toString());
        }
    }


    //流程表

    //查询是否有地块提交到省级
    @RequestMapping(value = "/queryRelatedk", method = RequestMethod.POST)
    public AjaxResult queryRelatedk(@RequestBody Map<String, Object> parm) {
        //所有相关地块
        List<Map<String, Object>> rest = xjtbTbBaseService.queryRelatedk(parm);
        //未提交的地块
        List<String> tbbhs = new ArrayList<String>();
        //已经提交的地块
        List<String> tjtbbhs1 = new ArrayList<String>();
        //图斑已经被拆分  地块没有被提交到市级
        String str = "";
        if (rest != null) {
            if (rest.size() > 0) {
                for (int i = 0; i < rest.size(); i++) {
                    String tbbh = rest.get(i).get("tbbh").toString();
                    String dkzt = rest.get(i).get("dkzt").toString();
                    if (!dkzt.equals("8")) {
                        tbbhs.add(tbbh);
                        str += "(" + rest.get(i).get("tbbh") + ")";
                    } else {
                        tjtbbhs1.add(tbbh);
                        str += "(" + rest.get(i).get("tbbh") + ")";
                    }
                }
            }
            if (rest.size() == tbbhs.size() && tjtbbhs1.size() == 0) {
                return AjaxResult.success("获取关联图斑 成功", str);
            } else {
                return AjaxResult.error("获取关联图斑 成功", str);
            }
        }
        return AjaxResult.error("获取关联图斑 失败", -1);
    }


    @Log(title = "卫片核查反馈退回接口", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/th", method = RequestMethod.POST)
    public AjaxResult shengTh(@RequestBody Map<String, Object> parms) {
        try {
            parms.put("type", "th");
            String rest = provAuditingService.getGtyData(parms);
            return AjaxResult.success("", rest);
        } catch (Exception ex) {
            return AjaxResult.error("退回失败", ex.toString());
        }
    }

    @Log(title = "卫片核查反馈提交接口", businessType = BusinessType.OTHER)
    @RequestMapping(value = "/tj", method = RequestMethod.POST)
    public AjaxResult tj(@RequestBody Map<String, Object> parms) {
        try {
            parms.put("type", "tj");
            String rest = provAuditingService.getGtyData(parms);
            return AjaxResult.success("", rest);
        } catch (Exception ex) {
            return AjaxResult.error("提交失败", ex.toString());
        }
    }

    //暂存
    @RequestMapping(value = "/saveLz", method = RequestMethod.POST)
    public AjaxResult saveLz(@RequestBody Map<String, Object> parm) {
        try {
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            parm.put("czr", loginUser.getUsername());
            parm.put("realname", loginUser.getSysUser().getNickName());
            Integer rest = provAuditingService.saveLz(parm);
            return AjaxResult.success("保存 成功", rest);
        } catch (Exception ex) {
            return AjaxResult.error("保存 失败", ex.toString());
        }
    }
}
